package com.gpStudy.design.single;

/**
 * 懒汉式，同步块
 *
 */
public class LazySingleton_DoubleCheck {

    private LazySingleton_DoubleCheck() {
    }

    private static LazySingleton_DoubleCheck lazySingleton;

    public static LazySingleton_DoubleCheck getInstance(){
        if(null == lazySingleton){
            synchronized(LazySingleton_DoubleCheck.class){

                lazySingleton = new LazySingleton_DoubleCheck();
                /*
                * 1.分配内存给这个对象
                * 2.初始化对象
                * 3.设置 lazySingleton 指向刚分配的内存地址
                *
                * */
            }
        }
        return lazySingleton;
    }
}
